<template>
    <div class="container" @click="download">
        下载图片
    </div>
</template>

<script setup>

const download = async () => {
    const url = '/api/upload/stream';
    const res = await fetch(url).then(res => res.arrayBuffer());
    console.log('res', res);
    const a = document.createElement('a');
    a.href = URL.createObjectURL(new Blob([res], {}));
    a.download = 'test.zip';
    a.click();
    a.remove();
};

</script>

<style lang="scss" scoped>
.container{
    margin: 20px;
    background: yellowgreen;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    color: #fff;
    border-radius: 3px;
    transition: all 0.3s;
    &:hover{
        background: #35cd32;
    }
}
</style>